﻿@using WB.Core.SharedKernels.DataCollection.Implementation.Aggregates.InterviewEntities
@model WB.Core.BoundedContexts.Headquarters.Views.InterviewHistory.InterviewHistoryView
           

@{
    ViewBag.Title = @Pages.InterviewHistory_Header;
    ViewBag.SpecificPageCaption = @Pages.InterviewHistory_Header;
}

@{
    string AsTimeZone(TimeSpan? offset)
    {
        if (offset == null)
        {
            return "";
        }

        var sign = offset.Value >= TimeSpan.Zero ? "+" : "-";
        var name = TimeZoneInfo.GetSystemTimeZones().FirstOrDefault(tz => tz.BaseUtcOffset == offset.Value);
        if (name != null)
        {
            return name.DisplayName.Substring(1, name.DisplayName.IndexOf(')') - 1);
        }

        return sign + offset.Value.ToString(@"hh\:mm");
    }
}

<main class="main">
    <div class="container-fluid">
        <div class="row">
            <div class="main-information-no-filter">
                <partial name="_alerts"/>
                <div class="page-header clearfix">
                    <h1>@Pages.InterviewHistory_Header</h1>
                </div>
                <table class="table table-striped table-condensed">
                    <thead>
                    <tr>
                        <th>Action</th>
                        <th>Parameters</th>
                        <th>Originator</th>
                        <th>Role</th>
                        <th>Timestamp (UTC)</th>
                        <th>TimeZone</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach (var item in Model.Records)
                    {
                        <tr>
                            <td>
                                @item.Action
                            </td>
                            <td>
                                @foreach (var parameter in item.Parameters)
                                {
                                    <small>@parameter.Key: </small>@parameter.Value
                                    <br/>
                                }
                            </td>
                            <td>
                                @item.OriginatorName
                            </td>
                            <td>
                                @item.OriginatorRole
                            </td>
                            <td>
                                @(item.Timestamp.HasValue ? item.Timestamp.Value.ToString(DateTimeFormat.DateWithTimeFormat) : "<NULL>")
                            </td>
                            <td>
                                @(AsTimeZone(item.Offset))
                            </td>
                        </tr>
                    }
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</main>
